﻿<Controls:MetroWindow x:Class="MetaTool.Views.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:myControls="clr-namespace:C4Net.Framework.MVVM;assembly=C4Net.Framework.MVVM"
        xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
        xmlns:trees="clr-namespace:MetaTool.ViewModels.Trees"
        WindowStartupLocation="CenterScreen"
        Title="Metamodel Tool" Height="400" Width="700">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro.Resources;component/Icons.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
                <ResourceDictionary Source="pack://application:,,,/C4Net.Framework.MVVM;component/Resources/C4NetControls.xaml" />
                <ResourceDictionary>
                    <Style x:Key="DescriptionHeaderStyle" TargetType="Label">
                        <Setter Property="FontSize" Value="22" />
                        <Setter Property="HorizontalAlignment" Value="Center" />
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Controls:MetroWindow.Flyouts>
        <Controls:FlyoutsControl x:Name="FlyoutViewModels">
            <Controls:FlyoutsControl.ItemContainerStyle>
                <Style TargetType="{x:Type Controls:Flyout}">
                    <Setter Property="Header" Value="{Binding Header}" />
                    <Setter Property="IsOpen" Value="{Binding IsOpen}" />
                    <Setter Property="Position" Value="{Binding Position}" />
                </Style>
            </Controls:FlyoutsControl.ItemContainerStyle>
        </Controls:FlyoutsControl>
    </Controls:MetroWindow.Flyouts>

    <Grid>
        <TabControl SelectedIndex="{Binding SelectedTabIndex}">
            <TabItem Header="Configuration" IsEnabled="False">
                <Grid Margin="5,5,5,5" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="60" />
                        <RowDefinition Height="10" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition Width="5" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <Controls:ProgressRing Grid.Row="0" Grid.Column="0" Grid.RowSpan="9" Grid.ColumnSpan="6" IsActive="True" Visibility="{Binding IsLoadingTables, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Select access file:" TextAlignment="Right" VerticalAlignment="Center"/>
                    <TextBox Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Height="20" 
                             Style="{StaticResource OpenFileMetroTextBox}"
                             Controls:TextboxHelper.Watermark="Enter access file path" 
                             Controls:TextboxHelper.ButtonCommand="{Binding BrowseFileCommand}"
                             Text="{Binding SelectedPath, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}"/>
                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Select template:" TextAlignment="Right" VerticalAlignment="Center"/>
                    <ComboBox x:Name="TemplateList"  Grid.Row="2" Grid.Column="2" Height="20" SelectedItem="{Binding SelectedTemplate}"></ComboBox>
                    <TextBlock Grid.Row="4" Grid.Column="0" Text="Generate Metamodel:" TextAlignment="Right" VerticalAlignment="Center"/>
                    <Controls:ToggleSwitch Grid.Row="4" Grid.Column="2" HorizontalAlignment="Left" Width="100" IsChecked="{Binding IncludeMeta}"/>
                    <TextBlock Grid.Row="6" Grid.Column="0" Text="Select output path:" TextAlignment="Right" VerticalAlignment="Center"/>
                    <TextBox Grid.Row="6" Grid.Column="2" VerticalAlignment="Center" Height="20" 
                             Style="{StaticResource OpenFileMetroTextBox}"
                             Controls:TextboxHelper.Watermark="Enter output path" 
                             Controls:TextboxHelper.ButtonCommand="{Binding BrowseFolderCommand}"
                             Text="{Binding SelectedOutputPath, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}"/>
                    <Button Grid.Row="10" Grid.Column="4" Command="{Binding MoveToPageTablesCommand}" 
                            Style="{DynamicResource MetroCircleButtonStyle}">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_next}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                </Grid>
            </TabItem>
            <TabItem Header="Select Tables" IsEnabled="False" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="10" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="60" />
                        <RowDefinition Height="10" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <Controls:ProgressRing Grid.Row="1" Grid.Column="2" IsActive="True" Visibility="{Binding IsLoadingTables, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                    <TreeView Grid.Row="1" Grid.Column="2" ItemsSource="{Binding RootEntities}"
                              Visibility="{Binding IsNotLoadingTables, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <TreeView.Resources>
                            <HierarchicalDataTemplate ItemsSource="{Binding Sons}" DataType="{x:Type trees:EntityViewModel}">
                                <StackPanel Orientation="Horizontal">
                                    <CheckBox Focusable="False" IsChecked="{Binding IsSelected}" VerticalAlignment="Center" />
                                    <Label Content="{Binding Name}"/>
                                </StackPanel>
                            </HierarchicalDataTemplate>
                        </TreeView.Resources>
                    </TreeView>
                    <Button Grid.Row="2" Grid.Column="1" 
                            Style="{DynamicResource MetroCircleButtonStyle}" cal:Message.Attach="[Event Click] = [Action MoveToPageConfiguration]">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_previous}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                    <Button Grid.Row="2" Grid.Column="3" 
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            cal:Message.Attach="[Event Click] = [Action MoveToPageParameters]">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_next}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2" Height="30" HorizontalAlignment="Center">
                        <Button x:Name="SelectAllEntities" Width="100" Margin="5,0,5,0">Select All</Button>
                        <Button x:Name="UnselectAllEntities" Width="100" Margin="5,0,5,0">Select None</Button>
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="Parameters" IsEnabled="False">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="10" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="60" />
                        <RowDefinition Height="10" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <DataGrid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" 
                              ItemsSource="{Binding Parameters}" 
                              SelectedItem="{Binding SelectedParameter}"
                              Style="{StaticResource AzureDataGrid}"
                              AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Key}" Header="KEY" Width="100" IsReadOnly="True"/>
                            <DataGridTextColumn Binding="{Binding Value}" Header="VALUE" Width="1*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button Grid.Row="2" Grid.Column="1" 
                            Style="{DynamicResource MetroCircleButtonStyle}" cal:Message.Attach="[Event Click] = [Action MoveToPageTablesBack]">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_previous}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                    <Button Grid.Row="2" Grid.Column="3" 
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            Command="{Binding MoveToPageBuildCommand}">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_next}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2" Height="30" HorizontalAlignment="Center">
                        <Button x:Name="AddNewKeyValue" Width="100" Margin="5,0,5,0">New</Button>
                        <Button Command="{Binding EditKeyValueCommand}" Width="100" Margin="5,0,5,0">Edit</Button>
                        <Button Command="{Binding RemoveKeyValueCommand}" Width="100" Margin="5,0,5,0">Remove</Button>
                    </StackPanel>

                </Grid>
            </TabItem>
            <TabItem Header="Build" IsEnabled="False">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="10" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="60" />
                        <RowDefinition Height="10" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="60" />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Vertical">
                        <Label Content="{Binding ProgressMessage}" Margin="0,10,0,0" Style="{StaticResource DescriptionHeaderStyle}"/>
                        <ProgressBar Height="15" Width="200" Margin="0, 10, 0, 0" Value="{Binding ProgressValue}" />
                    </StackPanel>
                    <Button Grid.Row="2" Grid.Column="1" 
                            Style="{DynamicResource MetroCircleButtonStyle}" cal:Message.Attach="[Event Click] = [Action MoveToPageParameters]">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_previous}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                    <Button Grid.Row="2" Grid.Column="3" 
                            Style="{DynamicResource MetroCircleButtonStyle}" cal:Message.Attach="[Event Click] = [Action DoClose]">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.Fill>
                                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_close}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Controls:MetroWindow>
